//
//  OrderInfoView.m
//  WeiYiMei
//
//  Created by 李叶夫 on 2019/4/14.
//  Copyright © 2019年 liyefu. All rights reserved.
//

#import "OrderInfoView.h"
#import "OrderEntity.h"

@interface OrderInfoView ()

@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *titleLab;

@property (nonatomic, strong) UILabel *orderCodeLab;
@property (nonatomic, strong) UILabel *orderCode;

@property (nonatomic, strong) UILabel *orderDateLab;
@property (nonatomic, strong) UILabel *orderDate;

@property (nonatomic, strong) UILabel *orderPayDateLab;
@property (nonatomic, strong) UILabel *orderPayDate;

@property (nonatomic, strong) UILabel *orderCompleteDateLab;
@property (nonatomic, strong) UILabel *orderCompleteDate;

@property (nonatomic, strong) UILabel *orderRemLab;
@property (nonatomic, strong) UILabel *orderRem;

@end

@implementation OrderInfoView

- (void)setOrderEntity:(OrderEntity *)orderEntity
{
    _orderEntity = orderEntity;
    self.orderCode.text = orderEntity.orderCode;
    self.orderDate.text = String(orderEntity.createTime);
    self.orderPayDate.text = String(orderEntity.payTime);
    self.orderCompleteDate.text = String(orderEntity.endTime);
    if (orderEntity.rem && orderEntity.rem.length) {
        self.orderRem.text = orderEntity.rem;
    }
    else {
        self.orderRem.text = @"无";
    }
}

- (void)setupSubViews
{
    self.icon = [[UIImageView alloc] init];
    self.icon.backgroundColor = kColorGradientEnd;
    [self addSubview:self.icon];
    
    self.titleLab = [[UILabel alloc] init];
    self.titleLab.font = [UIFont boldSystemFontOfSize:15];
    self.titleLab.textColor = kColor333333;
    [self addSubview:self.titleLab];
    self.titleLab.text = @"订单信息";
    
    self.orderCodeLab = [[UILabel alloc] init];
    self.orderCodeLab.font = [UIFont systemFontOfSize:13];
    self.orderCodeLab.textColor = kColor333333;
    [self addSubview:self.orderCodeLab];
    self.orderCodeLab.text = @"订单编号:";
    
    self.orderCode = [[UILabel alloc] init];
    self.orderCode.font = [UIFont systemFontOfSize:13];
    self.orderCode.textColor = kColor333333;
    [self addSubview:self.orderCode];
    self.orderCode.text = @"3456789098765434598";
    
    
    self.orderDateLab = [[UILabel alloc] init];
    self.orderDateLab.font = [UIFont systemFontOfSize:13];
    self.orderDateLab.textColor = kColor333333;
    [self addSubview:self.orderDateLab];
    self.orderDateLab.text = @"创建时间:";
    
    self.orderDate = [[UILabel alloc] init];
    self.orderDate.font = [UIFont systemFontOfSize:13];
    self.orderDate.textColor = kColor333333;
    [self addSubview:self.orderDate];
    self.orderDate.text = @"2019-03-21 12:34:27";
    
    self.orderPayDateLab = [[UILabel alloc] init];
    self.orderPayDateLab.font = [UIFont systemFontOfSize:13];
    self.orderPayDateLab.textColor = kColor333333;
    [self addSubview:self.orderPayDateLab];
    self.orderPayDateLab.text = @"付款时间:";
    
    self.orderPayDate = [[UILabel alloc] init];
    self.orderPayDate.font = [UIFont systemFontOfSize:13];
    self.orderPayDate.textColor = kColor333333;
    [self addSubview:self.orderPayDate];
    self.orderPayDate.text = @"2019-03-21 12:34:27";
    
    
    self.orderCompleteDateLab = [[UILabel alloc] init];
    self.orderCompleteDateLab.font = [UIFont systemFontOfSize:13];
    self.orderCompleteDateLab.textColor = kColor333333;
    [self addSubview:self.orderCompleteDateLab];
    self.orderCompleteDateLab.text = @"完成时间:";
    
    self.orderCompleteDate = [[UILabel alloc] init];
    self.orderCompleteDate.font = [UIFont systemFontOfSize:13];
    self.orderCompleteDate.textColor = kColor333333;
    [self addSubview:self.orderCompleteDate];
    self.orderCompleteDate.text = @"2019-03-21 12:34:27";
    
    self.orderRemLab = [[UILabel alloc] init];
    self.orderRemLab.font = [UIFont systemFontOfSize:13];
    self.orderRemLab.textColor = kColor333333;
    [self addSubview:self.orderRemLab];
    self.orderRemLab.text = @"订单备注:";
    
    self.orderRem = [[UILabel alloc] init];
    self.orderRem.font = [UIFont systemFontOfSize:13];
    self.orderRem.textColor = kColor333333;
    self.orderRem.numberOfLines = 0;
    [self addSubview:self.orderRem];
    self.orderRem.text = @"无";
    
}

- (void)setupConstraints
{
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self).offset(15);
        make.width.equalTo(@2);
        make.height.equalTo(@15);
    }];
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.icon);
        make.left.equalTo(self.icon.mas_right).offset(5);
    }];
    
    [self.orderCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon);
        make.top.equalTo(self.titleLab.mas_bottom).offset(15);
    }];
    
    [self.orderCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderCodeLab.mas_right).offset(16);
        make.right.lessThanOrEqualTo(self).offset(-15);
        make.centerY.equalTo(self.orderCodeLab);
    }];
    
    [self.orderDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon);
        make.top.equalTo(self.orderCode.mas_bottom).offset(12);
    }];
    
    [self.orderDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderDateLab.mas_right).offset(16);
        make.right.lessThanOrEqualTo(self).offset(-15);
        make.centerY.equalTo(self.orderDateLab);
    }];
    
    [self.orderPayDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon);
        make.top.equalTo(self.orderDate.mas_bottom).offset(12);
    }];
    
    [self.orderPayDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderPayDateLab.mas_right).offset(16);
        make.right.lessThanOrEqualTo(self).offset(-15);
        make.centerY.equalTo(self.orderPayDateLab);
    }];
    
    [self.orderCompleteDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon);
        make.top.equalTo(self.orderPayDate.mas_bottom).offset(12);
    }];
    
    [self.orderCompleteDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderCompleteDateLab.mas_right).offset(16);
        make.right.lessThanOrEqualTo(self).offset(-15);
        make.centerY.equalTo(self.orderCompleteDateLab);
    }];
    
    [self.orderRemLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon);
        make.top.equalTo(self.orderCompleteDate.mas_bottom).offset(12);
    }];
    
    [self.orderRem mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderRemLab.mas_right).offset(16);
        make.right.lessThanOrEqualTo(self).offset(-15);
        make.top.equalTo(self.orderRemLab);
        make.bottom.equalTo(self).offset(-15);
    }];
}

@end
